﻿#include "StdAfx.h"		//   U҉U҉U	 for unicoude save
#include "TestFeatTree.h"

/*---------------------- Pro/Toolkit Includes ------------------------*/
#include "ProToolkit.h"
#include "ProFeature.h"
#include "ProElemId.h"
#include "ProExtrude.h"
#include "ProModFeat.h"
#include "ProStdSection.h"
#include "ProElement.h"
#include "ProElempath.h"
#include "ProFeatType.h"
#include "ProFeatForm.h"
#include "ProSelection.h"
#include "ProSection.h"


#include "ProDtmCsys.h"
#include "ProMessage.h"
#include "ProUtil.h"
#include "ProTKRunTime.h"
#include "TestError.h"
#include "witotk\wProElement.hpp"
#include <iostream>
#include "witotk\wProSelection.hpp"
#include "witotk\wProException.hpp"
#include "witotk\ProElemIdType.hpp"

using namespace witotk;

#define C_LOG(a) ProTKPrintf ("Status for %s is = %d\n", a, status ); \
	ERROR_CHECK( a, "UgSktExtrusionCreate.c", status );

#define C_PRINT(a) ProTKPrintf ( "%s\n", a);

static ProFileName message_file; 

/*---------------------- Function Prototypes -------------------------*/
ProError ProDemoGeneralCsysCreate();

/*------------------------- External Data ----------------------------*/
ProError ProDemoSectCreate();


TestFeatTree::TestFeatTree(void)
{
}


TestFeatTree::~TestFeatTree(void)
{
}

ProError TestFeatTree::ProDemoGeneralCsysCreate()
{
	ProErrorlist            errors;
	ProMdl                  model;
	ProModelitem            model_item;
	ProSelection            model_sel;
	ProFeature              feature;
	ProFeatureCreateOptions opts[1];
	ProAsmcomppath          *p_comp_path = NULL;
	ProValue                value;
	char                    name[PRO_NAME_SIZE];
	ProError		  status;

	ProElement pro_e_feature_tree;
	ProElement pro_e_feature_type;
	ProElement pro_e_std_feature_name;
	ProElement pro_e_csys_origin_constrs;
	ProElement pro_e_csys_origin_constr;
	ProElement pro_e_csys_origin_constr_ref;
	ProElement pro_e_csys_offset_type;
	ProElement pro_e_csys_orientmoves;
	ProElement pro_e_csys_orientmove;
	ProElement pro_e_csys_orientmove_move_type;
	ProElement pro_e_csys_orientmove_move_val;
	ProElement pro_e_csys_orient_by_method;

	ProName 	wide_string;
	ProValueData 	value_data;
	ProSelection * p_select;
	int 		n_select;
	ProBoolean 	is_interactive = PRO_B_TRUE;

	ProStringToWstring ( message_file, "utilities.txt" ); 

	/*---------------------------------------------------------------*\
	Populating root element PRO_E_FEATURE_TREE 
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_FEATURE_TREE *** " );
	status = ProElementAlloc ( PRO_E_FEATURE_TREE, &pro_e_feature_tree ); 
	C_LOG( " ProElementAlloc " );

	/*---------------------------------------------------------------*\
	Populating element PRO_E_FEATURE_TYPE 
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_FEATURE_TYPE *** " );
	status = ProElementAlloc ( PRO_E_FEATURE_TYPE, &pro_e_feature_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_FEAT_CSYS; /* 979 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_feature_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_feature_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating element PRO_E_STD_FEATURE_NAME
	\*---------------------------------------------------------------*/

	C_PRINT( " *** Processing Element PRO_E_STD_FEATURE_NAME *** " );
	status = ProElementAlloc ( PRO_E_STD_FEATURE_NAME, 
		&pro_e_std_feature_name ); 
	C_LOG( " ProElementAlloc " );
	ProStringToWstring ( wide_string, "MY_CS0" );
	value_data.type = PRO_VALUE_TYPE_WSTRING;
	value_data.v.w = wide_string;
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_std_feature_name, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_std_feature_name );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIGIN_CONSTRS
	\*---------------------------------------------------------------*/

	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIGIN_CONSTRS *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIGIN_CONSTRS, 
		&pro_e_csys_origin_constrs );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_csys_origin_constrs  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIGIN_CONSTR
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIGIN_CONSTR *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIGIN_CONSTR, 
		&pro_e_csys_origin_constr );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_csys_origin_constrs, NULL, 
		pro_e_csys_origin_constr  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIGIN_CONSTR_REF
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIGIN_CONSTR_REF *** " );
	status = ProMessageDisplay ( message_file, "Select a reference CSYS");
	C_LOG( " ProMessageDisplay" );
	ProTKPrintf ( "Please select csys_ID_25 type of Modelitem\n");
	status = ProSelect ( "csys", 1, NULL, NULL, NULL, NULL, 
		&p_select, &n_select );
	C_LOG( " ProSelect" );
	if ( n_select <= 0 ) return PRO_TK_GENERAL_ERROR; 
	status = ProElementAlloc ( PRO_E_CSYS_ORIGIN_CONSTR_REF, 
		&pro_e_csys_origin_constr_ref );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_SELECTION;
	value_data.v.r = p_select[0];
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_origin_constr_ref, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_origin_constr, NULL, 
		pro_e_csys_origin_constr_ref );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_OFFSET_TYPE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_OFFSET_TYPE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_OFFSET_TYPE, 
		&pro_e_csys_offset_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_OFFSET_CARTESIAN; /* 0 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_offset_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_csys_offset_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVES *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVES, 
		&pro_e_csys_orientmoves );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_csys_orientmoves  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, 
		&pro_e_csys_orientmove );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_X; /* 3 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_DOUBLE;
	value_data.v.d = 0.000000;
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_val, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, 
		&pro_e_csys_orientmove );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_Y; /* 4 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_DOUBLE;
	value_data.v.d = -90.000000;
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_val, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, 
		&pro_e_csys_orientmove );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_Z; /* 5 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_DOUBLE;
	value_data.v.d = 0.000000;
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_val, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, &pro_e_csys_orientmove );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_X; /* 0 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 	
		&pro_e_csys_orientmove_move_val );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_DOUBLE;
	value_data.v.d = 100.000000;
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_val, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, &pro_e_csys_orientmove );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_Y; /* 1 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_DOUBLE;
	value_data.v.d = 200.000000;
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_val, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE, &pro_e_csys_orientmove );
	C_LOG( " ProElementAlloc" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmoves, NULL, 
		pro_e_csys_orientmove  );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_TYPE, 
		&pro_e_csys_orientmove_move_type );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_Z; /* 2 */ 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_type, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_type );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENTMOVES
	-> PRO_E_CSYS_ORIENTMOVE
	-> PRO_E_CSYS_ORIENTMOVE_MOVE_VAL
	\*---------------------------------------------------------------*/
	C_PRINT( " *** Processing Element PRO_E_CSYS_ORIENTMOVE_MOVE_VAL *** " );
	status = ProElementAlloc ( PRO_E_CSYS_ORIENTMOVE_MOVE_VAL, 
		&pro_e_csys_orientmove_move_val );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_DOUBLE;
	value_data.v.d = 300.000000;
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orientmove_move_val, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_csys_orientmove, NULL, 
		pro_e_csys_orientmove_move_val );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Populating  element PRO_E_CSYS_ORIENT_BY_METHOD
	\*---------------------------------------------------------------*/
	status = ProElementAlloc ( PRO_E_CSYS_ORIENT_BY_METHOD, 
		&pro_e_csys_orient_by_method );
	C_LOG( " ProElementAlloc " );
	value_data.type = PRO_VALUE_TYPE_INT;
	value_data.v.i = PRO_CSYS_ORIENT_BY_SEL_CSYS_AXES; 
	status = ProValueAlloc ( &value );
	C_LOG( " ProValueAlloc" );
	status = ProValueDataSet ( value, &value_data );
	C_LOG( " ProValueDataSet" );
	status = ProElementValueSet ( pro_e_csys_orient_by_method, value );
	C_LOG( " ProElementValueSet" );
	status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, 
		pro_e_csys_orient_by_method );
	C_LOG( " ProElemtreeElementAdd" );

	/*---------------------------------------------------------------*\
	Creating the feature in the current model.
	\*---------------------------------------------------------------*/
	status = ProMdlCurrentGet (&model);
	if ( status != PRO_TK_NO_ERROR ) return ( status );
	status = ProMdlToModelitem( model, &model_item ); 
	status = ProSelectionAlloc (p_comp_path, &model_item,
		&model_sel);

	opts[0] = PRO_FEAT_CR_DEFINE_MISS_ELEMS;
	status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1,
		&feature, &errors);
	C_LOG (" ProFeatureCreate"); 

	status = ProElementFree (&pro_e_feature_tree ); 
	C_LOG (" ProElementFree"); 

	return ( status );
}

ProError TestFeatTree::ProDemoGeneralCsysCreateOtk()
{
	try
	{
		ProTKPrintf ( "Please select csys_ID_25 type of Modelitem\n");
		wProSelectionCollection_ptr selc = wProSelection::Select("csys",1);//选择坐标系
		wProSelection_ptr sc = selc[0];

		//Populating root element PRO_E_FEATURE_TREE 
		wProElemtree  pro_e_feature_tree;

		pro_e_feature_tree
			[FEATURE_TYPE(PRO_FEAT_CSYS)]
			[FEATURE_NAME(L"MY_CS0")]
			[CSYS_ORIGIN_CONSTRS()
				[CSYS_ORIGIN_CONSTR()
					[CSYS_ORIGIN_CONSTR_REF(*sc)]
				]
			]
			[CSYS_OFFSET_TYPE(PRO_CSYS_OFFSET_CARTESIAN)]
			[CSYS_ORIENTMOVES()
				[CSYS_ORIENTMOVE()
					[CSYS_ORIENTMOVE_MOVE_TYPE(PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_X)]
					[CSYS_ORIENTMOVE_MOVE_VAL(0.000000)]
				]
				[CSYS_ORIENTMOVE()
					[CSYS_ORIENTMOVE_MOVE_TYPE(PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_Y)]
					[CSYS_ORIENTMOVE_MOVE_VAL(-90.000000)]
				]
				[CSYS_ORIENTMOVE()
					[CSYS_ORIENTMOVE_MOVE_TYPE(PRO_CSYS_ORIENTMOVE_MOVE_OPT_ROT_Z)]
					[CSYS_ORIENTMOVE_MOVE_VAL(0.000000)]
				]
				[CSYS_ORIENTMOVE()
					[CSYS_ORIENTMOVE_MOVE_TYPE(PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_X)]
					[CSYS_ORIENTMOVE_MOVE_VAL(100.000000)]
				]
				[CSYS_ORIENTMOVE()
					[CSYS_ORIENTMOVE_MOVE_TYPE(PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_Y)]
					[CSYS_ORIENTMOVE_MOVE_VAL(200.000000)]
				]
				[CSYS_ORIENTMOVE()
					[CSYS_ORIENTMOVE_MOVE_TYPE(PRO_CSYS_ORIENTMOVE_MOVE_OPT_TRAN_Z)]
					[CSYS_ORIENTMOVE_MOVE_VAL(300.000000)]
				]
			]
			[CSYS_ORIENT_BY_METHOD(PRO_CSYS_ORIENT_BY_SEL_CSYS_AXES)]
		;
	
		using namespace ev;

		int c = ev::GetValue(pro_e_feature_tree,PV()<<wFEATURE_TYPE);
		wchar_t* cStr = ev::GetValue(pro_e_feature_tree,PV()<<wFEATURE_TYPE<<STD_FEATURE_NAME);

		int d = ev::GetValue(pro_e_feature_tree,wFEATURE_TYPE);
		wchar_t* e = ev::GetValue(pro_e_feature_tree,wFEATURE_TYPE<<STD_FEATURE_NAME<<STD_FEATURE_NAME);

		 // Creating the feature in the current model.
		ProMdl                  model;
		ProModelitem            model_item;
		ProSelection            model_sel;
		ProError status = ProMdlCurrentGet (&model);
		if ( status != PRO_TK_NO_ERROR ) return ( status );
		status = ProMdlToModelitem( model, &model_item ); 
		status = ProSelectionAlloc (NULL, &model_item,
			&model_sel);
		ProFeature              feature;
		ProFeatureCreateOptions opts[1];
		ProErrorlist            errors;
		opts[0] = PRO_FEAT_CR_DEFINE_MISS_ELEMS;
		status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1,
			&feature, &errors);
		PROE_THROW(status,"ProFeatureCreate");
	}
	catch (ProException& e)
	{
		std::wcout<<"error:"<<e.GetDescribe()<<std::endl;
		std::cout << typeid(e).name() << std::endl;  
	}
	return PRO_TK_NO_ERROR;
}


#undef C_LOG
#undef C_PRINT

 
//